<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.File" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%
    String path = "/usr/weaver/ecology/log/action/dsjxToSAP";
    LinkedList<File> list = new LinkedList<File>();
    List<String> fileNames = new ArrayList<>();
    File file = new File(path);
    try {
        if (file.exists()) {
            File[] files = file.listFiles();

            for (File thisFile : files) {
                if (thisFile.isDirectory()) {
                    list.add(thisFile);
                    continue;
                }
                System.out.println(thisFile.getName());
                fileNames.add(thisFile.getName());
            }

        } else {
            System.out.println("该文件将夹为空！！！");
        }
        File tempFile;
        for (Iterator itr = list.iterator(); itr.hasNext(); ) {
            tempFile = list.removeFirst();
            for (File thisFile : tempFile.listFiles()) {
                if (thisFile.isDirectory()) {
                    list.add(thisFile);
                    continue;
                }
                System.out.println(thisFile.getName());
                fileNames.add(thisFile.getName());
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(fileNames);
%>
<script src="/js/jquery/jquery_wev8.js"></script>
<script type="text/javascript">
    $(function () {
        var result = <%=jsonArray%>;

        if (result != null) {
            for (var i = 0; i < result.length; i++) {
                let template = "<a href='/log/action/dsjxToSAP/"+result[i].toString()+"'>" + result[i].toString() + "</a>";
                // console.log(template);
                $("#div1").append(template);
            }
        }
    });


</script>
<div id="div1">

</div>